<?php
/**
 * Created by PhpStorm.
 * User: Duke
 * Date: 2019/11/4
 * Time: 11:35
 */
namespace App\Model;

use App\Model\BaseModel;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Events\StatementPrepared;
class ArticleModel extends BaseModel{
    //表名
    protected $table = 'article';
    //获取列表
    public function getAllList(){
            return DB::table($this->table)->get()->toArray();
    }
    //condition 获取条件列表
    public function getConditionList($condition){
        return DB::table($this->table)
            ->join('article_category', 'article.cid', '=', 'article_category.id')
            ->where($condition)->get()->toArray();
    }
    //condition 获取单条数据
    public function find_info($condition){
        return DB::table($this->table)->where($condition)->first();
    }
    //保存数据
    public function insertInfo($data){
        return DB::table($this->table)->insert($data);
    }
    //修改数据
    public function update_info($id,$data){
        return DB::table($this->table)->where('id',$id)->update($data);
    }
    //删除数据
    public function del($id = ''){
        return DB::table($this->table)->delete(['id'=>$id]);
    }
}
